using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;using THSERP.BusinessEntities;using THSERP.BaseProvider;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using THSLib;using THSERP.BaseProvider;

namespace THSERP.Modules.Report
{
    public partial class RP010 : ReportForm
    {
        public RP010()
        {
            InitializeComponent();
        }

        private void fld_btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void RP010_Load(object sender, EventArgs e)
        {
            fld_lkeFK_ARCustomerID.Screen = this;
            fld_lkeFK_ARCustomerID.InitializeControl();
            fld_lkeARSaleOrderStatus.Screen = this;
            fld_lkeARSaleOrderStatus.InitializeControl();
            fld_dgcARRP010SaleOrders.Screen = this;
            fld_dgcARRP010SaleOrders.InitializeControl();
            fld_lblBranchName.Text = ((BRBranchsInfo)new BRBranchsController().GetObjectByID(THSApp.CurrentCompanyInfo.FK_BRBranchID)).BRBranchName;

            fld_btnApply_Click(new object(), new EventArgs());
        }

        private void fld_btnApply_Click(object sender, EventArgs e)
        {
            StringBuilder queryBuilder = new StringBuilder();
            queryBuilder.Append(GenerateSearchQuery(THSUtil.GetTableNameFromBusinessObjectType(typeof(ARSaleOrdersInfo))));
            DataSet ds = new ARSaleOrdersController().GetDataSet(queryBuilder.ToString());
            if (ds.Tables.Count > 0)
            {
                fld_dgcARRP010SaleOrders.DataSource = ds.Tables[0];
                fld_dgcARRP010SaleOrders.RefreshDataSource();
            }
        }
    }
}